package com.museum.controller;


import com.alibaba.fastjson.JSONObject;
import com.museum.base.BaseApiService;
import com.museum.base.BaseResponse;
import com.museum.controller.APi.ClueControllerAPI;
import com.museum.core.utils.RedisUtil;
import com.museum.entity.DO.Clue;
import com.museum.entity.DTO.CommitCol;
import com.museum.entity.DTO.QueryCol;
import com.museum.service.impl.ClueServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Ruiwen/yznl
 * @since 2021-01-05
 */


@RestController
@RequestMapping("/clue")
public class ClueController extends BaseApiService<JSONObject> implements ClueControllerAPI {
    @Autowired
    private ClueServiceImpl clueService;



    @Override
    public BaseResponse<JSONObject> addClue(Clue clue, HttpServletRequest request) {

        int result = clueService.addClue(clue,request);
        if(result>0){
            return setResultSuccess("添加成功");
        }else{
            return setResultError("添加失败");
        }
    }

    @Override
    public BaseResponse<JSONObject> getAllColByPage(long current, long limit,QueryCol queryCol) {
        JSONObject json = clueService.getAllColByPage(current,limit,queryCol);
        return setResultSuccess(json);
    }

    @Override
    public BaseResponse<JSONObject> deleteColById(Integer id) {
        int result =  clueService.deleteColById(id);
        if(result>0){
            return setResultSuccess("删除成功");
        }else{
            return setResultError("删除失败");
        }
    }

    @Override
    public BaseResponse<JSONObject> commitCol(CommitCol commitCol, HttpServletRequest request) {
        int result =  clueService.commitCol(commitCol,request);
        if(result>0){
            return setResultSuccess("审核完成");
        }else{
            return setResultError("审核失败,系统错误");
        }
    }
}

